SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
IF exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_adm_Delete_PurOrderFutureVersions]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_adm_Delete_PurOrderFutureVersions]
GO


CREATE PROCEDURE [dbo].[sp_adm_Delete_PurOrderFutureVersions] 
	@versionID integer
AS 
BEGIN
	--Borrado de informacion
	Delete from purchases_orders_futures_versions where purchase_order_version_id in (SELECT pov.purchase_order_version_id FROM purchases_orders_versions pov INNER JOIN biweeks_periods_versions bpv ON bpv.version_id=@versionID AND pov.biweek_period_version_id = bpv.biweek_period_version_id)
END